<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			*{
				margin: 0;
				padding: 0;
			}
		</style>
	</head>
	<body>
		<!-- 测试 -->
		<div style="width: 300px; height: 300px; background-color: pink;" id="div1"></div>
		
		<input type="text"  id="txt" value="" />
		<br>
		<!-- 计算多少天多少小时 -->
		<button type="button" id="work1">获取小时</button>
		<br>
		<!-- 计算温度 -->
		<button type="button" id="work2">获取温度</button>
		<br>
		<!-- 计算两个数的加减乘除 -->
		<p>
			<input type="text" id="num1" value="" />+
			<input type="text" id="num2" value="" />
			<button type="button" id="computed3">计算</button>
		</p>
		<p>
			<input type="text" id="num3" value="" />-
			<input type="text" id="num4" value="" />
			<button type="button" id="computed4">计算</button>
		</p>
		<p>
			<input type="text" id="num5" value="" />*
			<input type="text" id="num6" value="" />
			<button type="button" id="computed5">计算</button>
		</p>
		<p>
			<input type="text" id="num7" value="" />/
			<input type="text" id="num8" value="" />
			<button type="button" id="computed6">计算</button>
		</p>
		<!-- <br >
		<p>
			<input type="text" id="num9" value="" />
			<select>
				<option value ="">+</option>
				<option value ="">-</option>
				<option value ="">*</option>
				<option value ="">/</option>
			</select>
			<input type="text" id="num10" value="" />
			<button type="button" id="computed7">计算</button>
		</p> -->
		<script type="text/javascript">
			//绑定事件:当用户点击了id值叫div1的元素之后才去执行function后面大括号里面的代码
				div1.onclick =function(){
					//事件处理函数
					alert(1)
				}
			
			//作业1
			work1.onclick=function(){
				//总小时数
				var totalHours = txt.value;
				//工作天数
				var day=parseInt(totalHours/24);
				//工作的小时部分
				var hours=(totalHours%24)
				//console.log(totalHours-day*24);
				console.log(totalHours+"小时一共是:"+day+"天零"+hours+"小时")
			}
			
			//作业2 计算温度    接收华氏度转换为摄氏度
			work2.onclick=function(){
				//测试
				//alert(1)
				var huashidu = txt.value;
				var sheshidu =parseInt(5/9*(huashidu-32)*1000)/1000;//保留3位小数
				console.log(huashidu+"华氏度="+sheshidu+"℃")
			}
			//计算两个数的加减乘除
			computed3.onclick=function(){
				console.log(Number(num1.value)+Number(num2.value))
			}
			computed4.onclick=function(){
				console.log(Number(num3.value)-Number(num4.value))
			}
			computed5.onclick=function(){
				console.log(Number(num5.value)*Number(num6.value))
			}
			computed6.onclick=function(){
				console.log(Number(num7.value)/Number(num8.value))
			}
			//
			// computed7.onclick=function(){
			// 	var Nub1 =Number(num9.value);
			// 	var Nub2 = Number(num10.value);
			// 	var Nub3 =Number(num9.value)+Number(num10.value);
			// 	console.log(Nub1+"?"+Nub2+"="+Nub3)
			// }
		</script>
	</body>
</html>
